
var thumbuptytp = $('#thumbuptytp')[0].value;
var toolsBox = $('.toolsbox')

console.log(thumbuptytp)
if(thumbuptytp == 'true'){
    console.log(1111)
    $(toolsBox[0]).find('img')[0]
    console.log($(toolsBox[0]).find('img')[0])
    $(toolsBox[0]).find('img')[0].src = 'http://localhost:9091/images/tobarThumbUpactive.png'
    console.log(222)
}else{
    console.log(4444)
}

$(toolsBox[0]).on('click', function (e) {
    var questId = $('#question_id')[0].value;
    $.ajax({
        type: "get",
        url: "/thumbUp/" + questId,
        dataType: 'json',
        success: function (response) {
            if (response.code==200) {
                console.log(response);
                $(toolsBox[0]).find('img')[0].src = 'http://localhost:9091/images/tobarThumbUpactive.png'
                $(toolsBox[0]).find('span')[1].innerHTML = response.data;
                toastr.info("点赞成功！");
            } else if(response.code==2000){
                $(toolsBox[0]).find('img')[0].src = 'http://localhost:9091/images/thumbUpWhite.png'
                $(toolsBox[0]).find('span')[1].innerHTML = response.data;
                toastr.info(response.message);}
            else {
                toastr.error(response.message);
            }
        }
    });
})


$("#personal-watch").on('click', function (e) {
    var that = this
    var userId = $("#authorId").text();
    var userType = $("#userType").text();
    if (userType=="游客用户"){
        toastr.error("请登陆後关注！！！");
        return;
    }
    $.ajax({
        type: "post",
        url: "/subscribe/"+userId,
        dataType: 'json',
        success: function (response) {
            if (response.code==200) {
                toastr.success(response.message);
                console.log(that)
                $(that).css('background', '#f5f5f5')
                $(that).css('color', '#e33e33')
                $(that).text('取消关注')
            } else {
                if(response.code==2001){
                    $(that).css('background', '#e33e33')
                    $(that).css('color', '#fafafc')
                    $(that).text('关注')
                    toastr.error(response.message);
                }
            }
        }
    })
})